//package com.kfm.spring.config;
//
//import org.springframework.context.annotation.AnnotationConfigApplicationContext;
//import org.springframework.context.support.ClassPathXmlApplicationContext;
//import org.springframework.web.WebApplicationInitializer;
//import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
//import org.springframework.web.servlet.DispatcherServlet;
//
//import javax.servlet.MultipartConfigElement;
//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRegistration;
//
//public class MyWebApplicationInitializer implements WebApplicationInitializer {
//    @Override
//    public void onStartup(ServletContext servletContext) throws ServletException {
//        System.out.println("MyWebApplicationInitializer.onStartup");
//        // 注册 spring 容器
//        AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
//        applicationContext.register(SpringConfig.class);
//        applicationContext.refresh();
//
//
//        // 注册 dispatcherServlet
//        DispatcherServlet dispatcherServlet = new DispatcherServlet(applicationContext);
//        // 动态添加 servlet
//        ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcherServlet", dispatcherServlet);
//        servlet.addMapping("/");
//        servlet.setLoadOnStartup(1);
////        servlet.setMultipartConfig(new MultipartConfigElement("/temp"));
//
//        // 注册过滤器
//        // servletContext.addFilter("filter", new MyFilter()).addMappingForUrlPatterns(null, false, "/*");
//    }
//}
